﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Admin.CYT369.Com.WebBase
{
    public class SystemExceptionProcessorAttribute : Microsoft.AspNetCore.Mvc.Filters.ExceptionFilterAttribute
    {
        public override void OnException(Microsoft.AspNetCore.Mvc.Filters.ExceptionContext context)
        {
            var action = context.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor;

            Admin.CYT369.Com.DAL.Services.AppService.Instance.SaveAppLog("admin.cyt369.com",
                                                                           (action == null ? string.Empty : string.Format("{0}.{1}", action.ControllerName, action.ActionName)),
                                                                           context.Exception,
                                                                           client: context.HttpContext.User.Identity.Name,
                                                                           remoteIP: context.HttpContext.Connection.RemoteIpAddress.ToString());

            base.OnException(context);
        }


    }
}
